function psnr = PSNR(x, y)
% psnr = PSNR(x, y)
% 
% PSNR computes the peak signal-to-noise ratio of two images which are
% given as a struct and their colours in the range of [0 255].
%
% See also: SSIM
%
% 2013-07-25 --------------------------------------------------------------
% 
% Matthias J. Ehrhardt
% CMIC, University College London, UK
% 
% matthias.ehrhardt.11@ucl.ac.uk
% 
% -------------------------------------------------------------------------
    
    X = Struct2im(x);
    Y = Struct2im(y);
    
    d = mean( (X(:)-Y(:)).^2);
    psnr = 10*log10( 255.^2/d );
end